Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ADI MAX32690 microcontroller #9667

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

Brandon-Hurst
Copy link

@Brandon-Hurst Brandon-Hurst commented Sep 27, 2024

Description

Add support for 2 boards: MAX32690EVKIT and AD-APARD32690-SL.

Status

At the moment, this port only includes digitalio in addition to the supervisor and USB workflow required to get CircuitPython functioning. Pinouts listed are currently just the MCU pins; happy to change as needed to better match any requirements for form factor or pin function. I plan to follow this up with a busio PR soon, but will be more tied up in the next couple months. Still happy to make changes as needed to this PR though.

USB Endpoint Enumeration Change

There is a small important bit I had to change to the way CircuitPython handles settings up USB Endpoints:

  • TUSB has some devices (such as MAX32) which are not capable of having full-duplex endpoints. This is true for a few devices besides MAX32, but also for MAX32 (in particular a lot of others share the same IP).
  • There is a #define for TUD_ENDPOINT_ONE_DIRECTION_ONLY accounted for by TinyUSB, but not by the way CircuitPython initializes an endpoint on these devices. The change itself is very minimal -- it just increments the endpoint after setting up either an IN our OUT instead of both to an endpoint pair. I made it for all device classes and it should cover all cases for other devices as well.

Many thanks to @tannewt and @dhalbert for the help :)

U-ANALOG\BHurst and others added 20 commits August 14, 2024 14:29
- Added simple status LED for initial testing
- Generally cleaned up & implemented supervisor/port.c
- Added some additional commenting from supervisor headers
- Fixed a linkerscript issue copying .text into FLASH_ISR
- (build): added hex & bin targets for executable.
- (build): temporarily modified .ld due to issue exiting MAX32 ROM code
- (flash): added flash target for jlink & msdk, along with helper files under tools/
- Reorganized mpconfigport.mk for clarity
- Moved flash driver & LED/PB definitions to board files (mpconfigboard._)
…Placed in supervisor/port.c

- Moved LEDs & PBs from supervisor/port.c to boards/$(BOARD)/board.c for APARD
- Reviewed Processor.c in common-hal/microcontroller
- Prepared stubs for common-hal/microcontroller/Pin.c
…. - Enabled USB-based modules & dependencies in mpconfigport.mk
…umerates but has some issues starting interfaces for CDC/MSC/HID.
…be usable. - Had to adjust some shared modules to account for MAX32 devices not supporting IN/OUT endpoints on the same EP #
… Fixed bugs with Internal Flash filesystem. Files now write & read back correctly. - Added copyright headers for all files.
@tannewt tannewt self-requested a review September 27, 2024 16:38
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new port! I'm excited to try it. I've added a few comments. Nothing major.

ports/analog/Makefile Outdated Show resolved Hide resolved
ports/analog/boards/apard32690/README.md Outdated Show resolved Hide resolved
ports/analog/boards/apard32690/board.c Outdated Show resolved Hide resolved
ports/analog/boards/apard32690/pins.c Show resolved Hide resolved
ports/analog/boards/max32690evkit/board.c Outdated Show resolved Hide resolved
ports/analog/boards/max32690evkit/board.c Outdated Show resolved Hide resolved
Comment on lines +70 to +72
// todo (low): MSDK Hardware does not support open-drain configuration except
// todo (low): when directly managed by a peripheral such as I2C.
// todo (low): find a way to signal this to any upstream code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in this file can implement open drain itself by switching the output buffer off and on. Here is the SAMD code:

void common_hal_digitalio_digitalinout_set_value(
digitalio_digitalinout_obj_t *self, bool value) {
const uint8_t pin = self->pin->number;
const uint8_t port = GPIO_PORT(pin);
const uint32_t pin_mask = 1U << GPIO_PIN(pin);
if (value) {
if (self->open_drain) {
// Assertion: pull is off, so the pin is floating in this case.
// We do open-drain high output (no sinking of current)
// by changing the direction to input with no pulls.
hri_port_clear_DIR_DIR_bf(PORT, port, pin_mask);
} else {
hri_port_set_DIR_DIR_bf(PORT, port, pin_mask);
hri_port_set_OUT_OUT_bf(PORT, port, pin_mask);
}
} else {
hri_port_set_DIR_DIR_bf(PORT, port, pin_mask);
hri_port_clear_OUT_OUT_bf(PORT, port, pin_mask);
}
}

ports/analog/mpconfigport.h Show resolved Hide resolved
ports/analog/supervisor/port.c Show resolved Hide resolved
ports/analog/supervisor/port.c Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants